package com.teamclub.base.controllers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

@RestController("com.teamclub.base.controllers.CacheTestController")
@RequestMapping("/base/test")
public class CacheTestController {
    private Logger logger  = LoggerFactory.getLogger(CacheTestController.class);
    @CachePut("phone")
    @GetMapping("testCachePut")
    public String testCachePut(@RequestParam String key) {
        logger.info("pass with origin");
        return "HELLO WORLD" + key;
    }

    @Cacheable("phone")
    @GetMapping("testCachable")
    public String testCachable(@RequestParam String key) {
        logger.info("cacheable in origin");
        return "HELLO WORLD" + key;
    }

    @CacheEvict("phone")
    @GetMapping("testcacheEvict")
    public String testcacheEvict(@RequestParam String key) {
        return "DEL SUCCESS";
    }


}
